This chapter introduces the concepts behind working with files in the CodeWarrior IDE.
To learn about editing files, refer to "Editing Source Code" on page 133.
To learn about working with files using revision control systems, refer to "Using CodeWarrior IDE with Version Control Systems" on page 581.
The sections in this chapter are:
To create a new untitled window where source code or text may be entered, choose the New Text File command from the File Menu.
To learn more about text editing in the window you have just created, see "Editing Source Code" on page 133.
There are several ways to open a file with the CodeWarrior IDE. The methods discussed here are:
You can open two types of files:
To open a project file, choose the Open command from the File Menu. For information on opening CodeWarrior project files, see "Opening an Existing Project" on page 67.
To open a text file or a source code file, choose the Open command from the File Menu. The IDE displays an Open dialog box, as shown in Figure 4.1 (Windows), Figure 4.2 (Mac OS), and Figure 4.3 (Solaris).
The dialog box displays a list of the available project and text files in the current directory.
For more information about editing source code, see "Editing Source Code" on page 133.
If the file you wish to see appears in the File column of the project window's File or Link Order views, double-click the file name to open it. If the file is a text file, CodeWarrior opens it in an editor window.
Another way to open a file is to select it, and then press the Enter/Return key. You can select multiple files in the Project window, and open them all by pressing the Enter/Return key. If you do not know how to select multiple files in a project, refer to "Selecting Files and Groups" on page 76.
For more information about the File Column, refer to "File column" on page 44.
Another way to open a source file is to use the Interface pop-up menu for a group. A similar menu is shown in Figure 4.4. From this pop-up menu you may select the file in the group that you want to open.
You can open a source file by choosing it from the Interface pop-up menu menu for the group that contains the file. This works even if the group is collapsed and the file is not visible in the project window.
To open a header or interface file, click on the Interface pop-up menu to see a list of files. Select the file you want to open from this list, as shown in Figure 4.4.
Note that header files inside "<...>" are system header files located within the Metrowerks CodeWarrior folder. Files without these symbols are header files that you have created. Your header files are stored in the same folder as your project or other Access Paths you have designated. To learn more about Access Paths and how to configure them, refer to "Access Paths" on page 323.
foo.cpp
and foo.h
. Then press Ctrl/Command-\Q to instantly switch between the two files.
To learn more about touching files, see "Touching and Untouching Files" on page 89.
To open an interface file from within a source file you are editing, click the Interface Pop-Up Menu at the top left of the editor window as shown in Figure 5.2 on page 136. This pop-up menu lists all interface or header files used by the source file. Select a file from the Interface Pop-Up Menu to open it in a new editor window.
Here is a different method. If you are editing any source code file, you can open an interface file mentioned anywhere in the text file with the Find and Open `Filename' command.
First, select text in the editor window containing the name of the interface file you would like to open. An example of a file name you might see in a C source code file is stdio.h
. You could select stdio.h
by double-clicking on the stdio
portion of the text. Then, choose the Find and Open `Filename' command from the File Menu.
In order for this keyboard shortcut to work, your source and interface files must have the same name, excluding the file name extensions. For example, if you are editing myFile.cpp
and you want to see the associated interface file, press Ctrl/Command \Q to display myFile.h
in a new editor window. To find these related files, the IDE searches a project according to the items in the Access Paths settings panel. To learn more, refer to "Access Paths" on page 323.
If you are editing a source code file and want to open a file without selecting any text, choose the Find and Open File command from the File Menu. This command will use the settings in the Access Paths for the project to search for the file to open.
After you choose Find and Open File, the CodeWarrior IDE then displays a dialog box, as shown in Figure 4.5. Type the name of the file you wish to search for in the Open editable text field.
If you want to search both System Paths pane and User Paths pane directory paths (all paths specified in the Access Paths), turn the Search Only in System Paths
option off.
To search only the CodeWarrior directory structure (the paths specified in the System Paths pane of the Access Paths), click on the Search Only in System Paths
option to enable it.
To learn more about Access Paths and how to configure them, refer to "Access Paths" on page 323 for more information.
To save your changes to the current editor file, choose the Save command from the File Menu. The CodeWarrior IDE saves your file to your hard disk.
The Save command is dimmed if the window is new and has no data, if the contents of the active window have already been saved, or when the active window is the project window.
Projects are saved when they are closed, when you quit or exit the CodeWarrior IDE, or when the Save A Copy As command is selected. You don't need to explicitly save projects.
The CodeWarrior IDE can automatically save changes to all your modified files whenever you choose the Preprocess, Precompile, Compile, Disassemble, Bring Up To Date, Make, or Run commands from the Project Menu.
Using the Save open files before build feature can save your work if your program should crash while running. However, if you're experimenting with a change and don't want to save changes, you may want to turn this option off.
To learn about how to enable or disable this feature, refer to the Save open files before build option in the section of this manual titled "Editor Settings" on page 269.
If you want to save a new untitled file or save a file under a new name, use the Save As command on the File Menu. If the file is in the current project, the CodeWarrior IDE updates the project to use the new name.
When you choose Save As from the File Menu, the CodeWarrior IDE displays the dialog box shown in Figure 4.6 (Windows), Figure 4.7 (Mac OS), or Figure 4.8 (Solaris).
Choose the Text or Stationery button to save the file as either a text file or a stationery file.
Choose the file location and name the file, then click the Save
button.
If the file is in the current project, the CodeWarrior IDE changes the file's entry in the project to match the saved name. If you don't want to change the project, but still want to save the file, you can refer to the following section, "Backing up files."
If you want to save a backup copy of a text file before you make some changes to the original, use the Save A Copy As command in the File Menu. The CodeWarrior IDE creates a copy of the file under a new name that you specify, but leaves the original file unchanged and does not change the currently-open project to use the new file name.
After choosing Save A Copy As from the File Menu, the CodeWarrior editor displays the dialog shown in Figure 4.6 (Windows), Figure 4.7 (Mac OS), or Figure 4.8 (Solaris). Specify the file's new location and choose a unique name for the file.
You can also choose whether to save the file as text stationery or a text file.
If the project window is the active window, Save A Copy As
allows you to save the project using a new name, or as a text file. You decide which type of project to create using the Save Project As Type pop-up menu shown in Figure 4.9. If you save the project as a text file, that text file will contain the names of all the files in the project.
To learn about saving a text file under a different text format, see "Options Pop-Up Menu" on page 138.
The topics in this section are:
To close a window, choose Close from the File Menu.
If you close a text file using the File Menu and have not yet saved your changes, the CodeWarrior IDE asks if you want to save the changes before closing the window, as shown in Figure 4.12. If you choose to close the file without saving your changes, all changes are lost.
Another way to close a window is by clicking the close box of the active window. This is exactly the same as choosing the Close command in the File Menu.
Closing an active project window automatically saves the project, and you will not see the dialog shown in Figure 4.12. For more on saving project files, consult "Saving a Project" on page 72.
The Close command also saves other properties of the window, such as the size, location, and the selected text in the active window. Refer to "Editor Settings" on page 269 for information on how to configure these options. If the appropriate options are enabled, the next time the source code file is opened, it will occupy the same position on your screen and the same text will be selected.
The Close command saves the window position information in a format that is compatible with the Macintosh Programmer's Workshop (MPW). If you open a saved CodeWarrior editor file with MPW, the same window parameters are respected. For more information about MPW, refer to the documentation on the CodeWarrior Reference CD.
Close All only closes editor and debugger windows. The Find dialog box, as well as project windows, remain open.
This command is available by pressing Ctrl-Shift-W.
This command is available when you press the Option key before clicking on the File
menu.
The topics in this section are:
To configure printing options, choose the printer setup appropriate for your platform. CodeWarrior displays the appropriate printer dialog box. Choose Print Setup (Windows) or Page Setup (Mac OS) from the File Menu to display the printer dialog box.
If you Click OK
, CodeWarrior saves the options for the next time you print any files.
To print a window, make the window active and choose the Print command from the File Menu. This menu command allows you to print some or all of the active window.
The CodeWarrior-specific options are:
If you've opened a text file and started editing it, then realize that you don't want to use the changes you've made, use the Revert command on the File Menu. When you select this command the dialog box shown in Figure 4.13 appears.
The topics in this section show you how to use the IDE's file comparison features:
The IDE's file comparison window displays two text files and the differences-insertions and deletions- between them. Figure 4.14 shows an example file comparison window. The window has controls to examine, add, and remove the differences between the files. The currently selected difference is shown with a darker color and outlined in black to contrast it from the other differences visible in the window.
The file comparison window has these parts:
Has buttons to apply or remove changes between the two files to the destination file. Table 4.1 describes the toolbar's buttons. The toolbar also has buttons to undo and redo changes to the source and destination files. For information on configuring toolbars, see "Customizing the IDE" on page 289.
Button
|
Description
|
---|---|
To open a file comparison window, choose Compare Files
from the
Search Menu
to show a dialog box that prompts you for two files, source and destination files, to compare. To use a file dialog box to browse for the source and destination files, click their respective
Choose
buttons. You may also drag and drop text files into their respective boxes.
Make sure that the Compare Files radio button, shown in Figure 4.15, is enabled. This allows you to select files by using the Choose buttons.
See "Folder Compare Options" on page 130 for information on the folder comparison options.
To show the comparison window after choosing files and setting options, click the Compare
button.
To view a difference between the two files, click its entry in the difference list. To apply the difference, click the Apply button in the toolbar or choose Apply Difference
from the
Search Menu
. To reverse a difference you've already applied, click the Unapply button or choose
Unapply Difference
from the
Search Menu
.
To compare two files that are already open in editor windows, click on the Editor Files pop-up menu next to the source and destination paths, as shown in Figure 4.15. A list of open editor windows appears. Choose a file name from the menu to make it the source or destination file. Click Compare once the source and destination files are chosen to display the comparison window.
To open a folder comparison window, choose Compare Files
from the
Search Menu
to show a dialog box that prompts you for two folders, the source and destination folders, to compare. To set these folders, drag and drop the folders into their respective boxes (Figure 4.16).
Select Only Show Different Files to only display files that are different in both folders in the Files In Both Folders list of the Compare Folders window (Figure 4.17). By default, this option is disabled, so all files in the source and destination folders are displayed.
See "Text Compare Options" on page 129 for information on the file comparison options.
When you click the Compare button, the IDE displays the Folder Compare Results Window, as shown in Figure 4.17. Source code files, header files, text files, and folders appear in plain face. All other files appear italicized.